package org.ktx.osr.data

import android.os.Parcel
import android.os.Parcelable

/**
 * 文件上传配置
 */
data class UploadConfig(
    val serverUrl: String,
    val apiKey: String? = null,
    val timeout: Long = 30000, // 30秒超时
    val maxRetries: Int = 3,
    val uploadOriginalFiles: Boolean = true, // 是否上传原始文件
    val uploadProcessedFiles: Boolean = true // 是否上传处理后的文件
) : Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.readString() ?: "",
        parcel.readString(),
        parcel.readLong(),
        parcel.readInt(),
        parcel.readByte() != 0.toByte(),
        parcel.readByte() != 0.toByte()
    )

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(serverUrl)
        parcel.writeString(apiKey)
        parcel.writeLong(timeout)
        parcel.writeInt(maxRetries)
        parcel.writeByte(if (uploadOriginalFiles) 1 else 0)
        parcel.writeByte(if (uploadProcessedFiles) 1 else 0)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<UploadConfig> {
        override fun createFromParcel(parcel: Parcel): UploadConfig {
            return UploadConfig(parcel)
        }

        override fun newArray(size: Int): Array<UploadConfig?> {
            return arrayOfNulls(size)
        }
    }
}

/**
 * 上传结果
 */
data class UploadResult(
    val success: Boolean,
    val originalFileUrl: String? = null,
    val processedFileUrl: String? = null,
    val errorMessage: String? = null
)
